#include "hpy.h"
#include <bits/stdc++.h>

using namespace std;

string genName(double p) {
    string s = rnd.next("[a-zA-Z]{0,18}");
    bool pb = false;
    for(char &c : s)
        if(!pb && rnd.next() < p) {
            c = ' ';
            pb = true;
        }else pb = false;
    return rnd.next("[a-zA-Z]{1}") + s + rnd.next("[a-zA-Z]{1}");
}

string genId() {
    return rnd.next("[0-9]{1,20}");
}

int main(int argc, char* argv[])
{
    registerGen(argc, argv, 1);
    auto [n, m, p] = tuple{opt<int>(1), opt<int>(2), opt<double>(3)};
    set<string> s;
    vector<pair<string, string> > v;
    while(v.size() < n) {
        string name = genName(p), id = genId();
        if(s.count(name) == 0 && s.count(id) == 0) {
            v.emplace_back(name, id);
            s.insert(name);
            s.insert(id);
        }
    }
    println(n);
    for(auto &[name, id] : v)
        println(name, id);

    println(m);
    for(int _ = 0; _ < m; _ ++) {
        if(rnd.next() < 0.05) {
            println(rnd.next(2) ? genName(p) : genId());
        }else{
            string s = rnd.next(2) ? v[rnd.next(n)].first : v[rnd.next(n)].second;
            if(rnd.next() < 0.05) s.erase(s.begin() + rnd.next(max(1, (int)s.length() - 1)));
            else if(rnd.next() < 0.05) s.insert(s.begin() + rnd.next(s.length() + 1), rnd.next('a', 'z'));
            else if(rnd.next() < 0.05) s.insert(s.begin() + rnd.next(s.length() + 1), rnd.next('A', 'Z'));
            println(s);
        }
    }
}
